
.globl _start

_start:
     msr SCR_EL3, xzr  // Ensure NS bit is initially clear, so secure copy of ICC_SRE_EL1 can be configured

    //
    // neither EL3 nor EL2 trap floating point or accesses to CPACR
    //
    // msr CPTR_EL3, xzr
    ldr x1, =0x00000100
    msr CPTR_EL3, x1
    // msr CPTR_EL2, xzr
    ldr x1, =0x000033ff
    msr CPTR_EL2, x1

    mov x0, #1 << 8
    msr CPTR_EL3, x0            /* sve trap */

    mov x0, #3 << 20
    mov x1, #3 << 16            /* sve Enable */
    orr x0, x0, x1              
    // 0x00330000
    msr cpacr_el1, x0           /* Enable FP/SIMD */
    msr mdscr_el1, xzr

    // config for el change
    ldr x1, =0x80000000
    msr HCR_EL2, x1

    adr x2, _bak
    adrp x1, _br_entry
    br x1

_bak:
    // exit run
    mov x1, #0x4
    ldr x2, =0x1300000
    strb w1, [x2]
    dsb sy

_i_wfe:
    wfe
    b _i_wfe

    ldr x1, =0x2230000
    br x1
